using System;
using System.Collections.Generic;
using System.Text;
using TinyServerLib;
using System.Windows.Forms;

using TinyLogger;

namespace WinformWebServer
{
    public class TextBoxLogger : ILoggerSink
    {

        Control control;

        public TextBoxLogger(Control control)
        {
            this.control = control;
        }

        private delegate void AddStatusCallback(LogLevel level, string status);

        public void AddLog(LogLevel level, string logString)
        {
            if (this.control.InvokeRequired)
            {
                AddStatusCallback d = new AddStatusCallback(AddLog);
                control.Invoke(d, new object[] { level, logString });
            }
            else
            {
                this.control.Text += logString + Environment.NewLine;
            }
        }

    }
}
